﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:loc="clr-namespace:Samba.Presentation" 
                    xmlns:properties="clr-namespace:Samba.Presentation.Properties" 
                    xmlns:ListViewEx="clr-namespace:Samba.Presentation.Common.ListViewEx;assembly=Samba.Presentation.Common" xmlns:Common="clr-namespace:Samba.Presentation.Common;assembly=Samba.Presentation.Common">
    
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/Samba.Presentation;component/Themes/MainExpanderResources.xaml" />
    </ResourceDictionary.MergedDictionaries>
    
    <properties:Settings x:Key="Settings" />
    
    <Style x:Key="LeftAlignedGridCell" TargetType="{x:Type DataGridCell}">
        <Style.Triggers>
            <Trigger Property="IsSelected" Value="True">
                <Setter Property="Background" Value="{StaticResource {x:Static SystemColors.InactiveBorderBrushKey}}" />
                <Setter Property="Foreground" Value="{StaticResource {x:Static SystemColors.WindowTextBrushKey}}"/>
            </Trigger>
            <Trigger Property="DataGridRow.IsFocused" Value="True">
                <Setter Property="Background" Value="{StaticResource {x:Static SystemColors.HighlightBrushKey}}" />
                <Setter Property="Foreground" Value="{StaticResource {x:Static SystemColors.HighlightTextBrushKey}}"/>
            </Trigger>
        </Style.Triggers>
        <Style.Setters>
            <Setter Property="BorderThickness" Value="0"/>
        </Style.Setters>
    </Style>

    <Style x:Key="RightAlignedGridCell" TargetType="{x:Type DataGridCell}" BasedOn="{StaticResource LeftAlignedGridCell}">
        <Style.Setters>
            <Setter Property="TextBlock.TextAlignment" Value="Right" />
        </Style.Setters>
    </Style>

    <Style x:Key="RightAlignedCellStyle" TargetType="{x:Type DataGridCell}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type DataGridCell}">
                    <Grid Background="{TemplateBinding Background}">
                        <ContentPresenter HorizontalAlignment="Right"
                                      VerticalAlignment="Center"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ItemsControlButtonStyle" TargetType="{x:Type Button}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <ContentPresenter HorizontalAlignment="Stretch"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="CollapsedTextStyle" TargetType="TextBlock">
        <Setter Property="Margin" Value="3"/>
        <Style.Triggers>
            <Trigger Property="Text" Value="">
                <Setter Property="Visibility" Value="Collapsed"/>
            </Trigger>
        </Style.Triggers>
    </Style>

    <LinearGradientBrush x:Key="IPhoneSteelBackground" EndPoint="0.5,1.272" StartPoint="0.5,0">
        <GradientStop Color="#FF9097A3" Offset="0"/>
        <GradientStop Color="#FF444D5B" Offset="1"/>
    </LinearGradientBrush>

    <loc:VisibilityConverter x:Key="VisibilityConverter" />

    <ListViewEx:BackgroundConvertor x:Key="backgroundConverter"/>
    <DataTemplate x:Key="HeaderTemplateSortAsc" >
        <Grid Height ="30" x:Name="HeaderTemplateSortAscGrid">
            <Grid.ColumnDefinitions >
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width ="Auto" />
            </Grid.ColumnDefinitions>
            <TextBlock Grid.Column ="0"  HorizontalAlignment="Center" 
						   VerticalAlignment ="Center"
						   x:Name ="HeaderText" 
						   TextTrimming="CharacterEllipsis" TextWrapping ="Wrap" 
						   Text="{Binding}" ToolTipService.ToolTip ="{Binding}" />
            <Path x:Name="arrow"
				   Grid.Column ="1"
				    Opacity ="0.7"
				   Fill ="{Binding ElementName=HeaderText, Path= Foreground}"
				   VerticalAlignment ="Center"
				   StrokeThickness = "1"
				   Data            = "M 5,10 L 15,10 L 10,5 L 5,10">
            </Path>
        </Grid>
    </DataTemplate>

    <DataTemplate x:Key="HeaderTemplateSortDesc">
        <Grid Height ="30">
            <Grid.ColumnDefinitions >
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width ="Auto" />
            </Grid.ColumnDefinitions>
            <TextBlock Grid.Column ="0"  HorizontalAlignment="Center"
						   VerticalAlignment ="Center"
						    x:Name ="HeaderText"
						   TextTrimming="CharacterEllipsis" TextWrapping ="Wrap"
						   Text="{Binding }" ToolTipService.ToolTip ="{Binding}"/>
            <Path x:Name="arrow"
					  Grid.Column ="1"
					  VerticalAlignment ="Center"                      
					  StrokeThickness = "1"
					  Opacity ="0.7" 
					   Fill ="{Binding ElementName=HeaderText, Path= Foreground}" 
					  Data            = "M 5,5 L 10,10 L 15,5 L 5,5">
            </Path>
        </Grid>
    </DataTemplate>

    <DataTemplate x:Key="HeaderTemplateSortNon">
        <DockPanel Height ="30">
            <TextBlock HorizontalAlignment="Center" TextTrimming="CharacterEllipsis"
						   VerticalAlignment ="Center"
						   TextWrapping ="Wrap" Text="{Binding }" ToolTipService.ToolTip ="{Binding}" />
        </DockPanel>
    </DataTemplate>

    <Style x:Key="BlueBackground" TargetType ="GridViewColumnHeader">
        <Setter Property ="Background" Value ="LightSlateGray" />
        <Setter Property ="Foreground" Value ="White" />
    </Style >

    <Style x:Key="SilverBackground" TargetType ="GridViewColumnHeader">
        <Setter Property ="Background" Value ="Gray" />
        <Setter Property ="Foreground" Value ="White" />
    </Style >

    <Style x:Key="BlueHeader" TargetType="TextBlock">
        <Setter Property ="Background" Value ="WhiteSmoke" />
        <Setter Property ="Foreground" Value ="Black" />
    </Style>

    <DataTemplate x:Key ="WrappedHeaderTemplate" >
        <DockPanel Height ="30">
            <TextBlock HorizontalAlignment="Center" TextTrimming="CharacterEllipsis"
							   VerticalAlignment ="Center"
							   TextWrapping ="Wrap" Text="{Binding }" ToolTipService.ToolTip ="{Binding}" />
        </DockPanel>
    </DataTemplate>

    <DataTemplate x:Key ="WrappedFooterTemplate" >
        <DockPanel Height ="25">
            <TextBlock HorizontalAlignment="Stretch" TextTrimming="CharacterEllipsis"
							    VerticalAlignment ="Center" FontSize="16" FontWeight="Bold"
                                TextAlignment="Right" TextWrapping ="Wrap" Text="{Binding }" ToolTipService.ToolTip ="{Binding}" />
        </DockPanel>
    </DataTemplate>

    <Style TargetType ="ListViewItem" x:Key="ListViewItemExContainerStyle">
        <Setter Property ="Template">
            <Setter.Value>
                <ControlTemplate TargetType ="{x:Type ListViewItem}">
                    <Grid Background ="{TemplateBinding Background}">
                        <GridViewRowPresenter x:Name="ItemContent" Focusable="False" Grid.Row="0">
                        </GridViewRowPresenter>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsSelected" Value="true">
                            <Setter Property="Background" Value="{StaticResource {x:Static SystemColors.HighlightBrushKey}}"/>
                            <Setter Property="Foreground" Value="{StaticResource {x:Static SystemColors.HighlightTextBrushKey}}"/>
                            <Setter Property="Height" Value="Auto"/>
                        </Trigger>

                    </ControlTemplate.Triggers>

                </ControlTemplate>
            </Setter.Value>
        </Setter>

        <Setter Property="Background">
            <Setter.Value>
                <Binding RelativeSource="{RelativeSource Self}" Converter="{StaticResource backgroundConverter}"/>
            </Setter.Value>
        </Setter>

        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="VerticalContentAlignment" Value="Stretch" />
        <Setter Property ="Height" Value ="Auto" />
    </Style>

    <Style x:Key="{x:Static GridView.GridViewScrollViewerStyleKey}" TargetType="{x:Type ScrollViewer}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ScrollViewer">
                    <Grid Background="{TemplateBinding Background}">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>

                        <DockPanel Margin="{TemplateBinding Padding}">
                            <ScrollViewer 
                                DockPanel.Dock="Top"
                                HorizontalScrollBarVisibility="Hidden"
                                VerticalScrollBarVisibility="Hidden"
                                Focusable="false">
                                <GridViewHeaderRowPresenter Margin="0,0,0,0"
                                          Columns="{Binding Path=TemplatedParent.View.Columns, RelativeSource={RelativeSource TemplatedParent}}"
                                          ColumnHeaderContainerStyle="{Binding Path=TemplatedParent.View.ColumnHeaderContainerStyle, RelativeSource={RelativeSource TemplatedParent}}"
                                          ColumnHeaderTemplate="{Binding Path=TemplatedParent.View.ColumnHeaderTemplate, RelativeSource={RelativeSource TemplatedParent}}"
                                          ColumnHeaderTemplateSelector="{Binding Path=TemplatedParent.View.ColumnHeaderTemplateSelector, RelativeSource={RelativeSource TemplatedParent}}"
                                          AllowsColumnReorder="{Binding Path=TemplatedParent.View.AllowsColumnReorder, RelativeSource={RelativeSource TemplatedParent}}"
                                          ColumnHeaderContextMenu="{Binding Path=TemplatedParent.View.ColumnHeaderContextMenu, RelativeSource={RelativeSource TemplatedParent}}"
                                          ColumnHeaderToolTip="{Binding Path=TemplatedParent.View.ColumnHeaderToolTip, RelativeSource={RelativeSource TemplatedParent}}"
                                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                            </ScrollViewer>

                            <ScrollContentPresenter Name="PART_ScrollContentPresenter"
                                    KeyboardNavigation.DirectionalNavigation="Local"
                                    CanContentScroll="True"
                                    CanHorizontallyScroll="False"
                                    CanVerticallyScroll="False" />
                        </DockPanel>

                        <ScrollBar Name="PART_HorizontalScrollBar"
                             Orientation="Horizontal"
                             Grid.Row="1"
                             Maximum="{TemplateBinding ScrollableWidth}"
                             ViewportSize="{TemplateBinding ViewportWidth}"
                             Value="{TemplateBinding HorizontalOffset}"
                             Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" />

                        <ScrollBar Name="PART_VerticalScrollBar"
                             Grid.Column="1"
                             Maximum="{TemplateBinding ScrollableHeight}"
                             ViewportSize="{TemplateBinding ViewportHeight}"
                             Value="{TemplateBinding VerticalOffset}"
                             Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" />

                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

   


</ResourceDictionary>